<cfsetting enablecfoutputonly="yes"> 

<cfparam name="attributes.xmldoc" default="">
<cfparam name="attributes.version" default="">

<cfswitch expression="#attributes.version#">
	<cfcase value="1">
	<cfset tmpstruct = StructNew()>
	<cfif FindNoCase("<MAX_TI_STATUS>",attributes.xmldoc,1)>
		<cfset tmpCode=ReFindNoCase("(<CODE>)(.*)(</CODE>)",attributes.xmldoc,1,true)>
		<cfset tmpMessage=ReFindNoCase("(<MESSAGE>)(.*)(</MESSAGE>)",attributes.xmldoc,1,true)>
		<cfset tmpStruct.actioncode=mid(attributes.xmldoc,tmpCode.pos[3],tmpCode.len[3])>
		<cfset tmpStruct.ActionMessage=mid(attributes.xmldoc,tmpMessage.pos[3],tmpMessage.len[3])>
		<cfset tmpstruct.result = True>
		<cfset tmpStruct.actiontype="Result">
	<cfelseif findnocase("</outputheader>",attributes.xmldoc)>
		<cfscript>
			tmpstruct = StructNew();	//writeoutput(htmlcodeformat(attributes.xmldoc));
			tmpvl = FindNoCase('</outputheader>', attributes.xmldoc, 1);  
			var.header = left(attributes.xmldoc, iif(tmpvl, tmpvl, 1));
			if ((attributes.xmldoc neq 'Connection Failure') and ReFindNoCase('<actionset>(.*)</actionset>', var.header, 1)) {  
				tmpvl = ReFindNoCase('<actionset>(.*)</actionset>', var.header, 1, true);
				var.actiontag = mid(var.header, tmpvl.pos[2], tmpvl.len[2]); 							//writeoutput(htmlcodeformat(var.actiontag));
				tmpvl = ReFindNoCase('type="([^"]*)"', var.actiontag, 1, true);
				tmpstruct.actiontype = mid(var.actiontag, tmpvl.pos[2], tmpvl.len[2]);
				tmpvl = ReFindNoCase('code="([^"]*)"', var.actiontag, 1, true);
				tmpstruct.actioncode = mid(var.actiontag, tmpvl.pos[2], tmpvl.len[2]);
				if (ReFindNoCase('message=', var.actiontag)) {
					tmpvl = ReFindNoCase('message="([^"]*)"', var.actiontag, 1, true);
					tmpstruct.actionmessage = mid(var.actiontag, tmpvl.pos[arraylen(tmpvl.pos)], tmpvl.len[arraylen(tmpvl.len)]); 
				}
				else {
					tmpstruct.actionmessage = "";
						}
				tmpstruct.result = true;
				}
			else {
				tmpstruct.result = false;
				tmpstruct.actiontype = 0;
				tmpstruct.actioncode = "";
				tmpstruct.actionmessage = "";
			}
		</cfscript>
	<cfelseif FindNoCase("tag mismatch",attributes.xmldoc,1)>
		<cfset tmpStruct.actioncode="">
		<cfset tmpStruct.ActionMessage="Max xml error. Please Contact Administrator">
		<cfset tmpstruct.result = True>
		<cfset tmpStruct.actiontype="Result">
		<cfset tmpStruct.xmlReturned=attributes.xmldoc>
	<cfelseif not FindNoCase(">",attributes.xmldoc,1)>
		<cfset tmpStruct.actioncode="0">
		<cfset tmpStruct.ActionMessage="Middleware xsl error,Please Contact Administrator">
		<cfset tmpstruct.result = True>
		<cfset tmpStruct.actiontype="Result">
	<cfelseif FindNoCase("<NODATAMAX/>",attributes.xmldoc)>
		<cfset tmpStruct.actioncode="0">
		<cfset tmpStruct.ActionMessage="No Max Information Returned">
		<cfset tmpstruct.result = True>
		<cfset tmpStruct.actiontype="Result">
	<cfelse>
		<cfset tmpStruct.actioncode="250">
		<cfset tmpStruct.ActionMessage="250">
		<cfset tmpstruct.result = True>
		<cfset tmpStruct.actiontype="Result">
	</cfif>
	<cfset caller.xti_get_xtistatus=duplicate(tmpstruct)>
	</cfcase>
	
	<cfdefaultcase>
	<cfscript>
		tmpstruct = StructNew();	//writeoutput(htmlcodeformat(attributes.xmldoc));
		tmpvl = FindNoCase('</outputheader>', attributes.xmldoc, 1);  
		var.header = left(attributes.xmldoc, iif(tmpvl, tmpvl, 1));
		if ((attributes.xmldoc neq 'Connection Failure') and ReFindNoCase('<actionset>(.*)</actionset>', var.header, 1)) {  
			tmpvl = ReFindNoCase('<actionset>(.*)</actionset>', var.header, 1, true);
			var.actiontag = mid(var.header, tmpvl.pos[2], tmpvl.len[2]); 							//writeoutput(htmlcodeformat(var.actiontag));
			tmpvl = ReFindNoCase('type="([^"]*)"', var.actiontag, 1, true);
			tmpstruct.actiontype = mid(var.actiontag, tmpvl.pos[2], tmpvl.len[2]);
			tmpvl = ReFindNoCase('code="([^"]*)"', var.actiontag, 1, true);
			tmpstruct.actioncode = mid(var.actiontag, tmpvl.pos[2], tmpvl.len[2]);
			if (ReFindNoCase('message=', var.actiontag)) {
				tmpvl = ReFindNoCase('message="([^"]*)"', var.actiontag, 1, true);
				tmpstruct.actionmessage = mid(var.actiontag, tmpvl.pos[arraylen(tmpvl.pos)], tmpvl.len[arraylen(tmpvl.len)]); 
			}
			else {
				tmpstruct.actionmessage = "";
					}
			tmpstruct.result = true;
			}
		else {
			tmpstruct.result = false;
			tmpstruct.actiontype = 0;
			tmpstruct.actioncode = "";
			tmpstruct.actionmessage = "";
		}
		// copy the structure to the return variable 
		caller.xti_get_xtistatus = tmpstruct;
	</cfscript>
	</cfdefaultcase>
</cfswitch>

<cfsetting enablecfoutputonly="no">